using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using PickGold.Charting.Utilities;
using PickGold.Charting.Design;

namespace PickGold.Charting
{
	[SRDescription("DescriptionAttributeCustomLabel_CustomLabel"), DefaultProperty("Text"), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class CustomLabel : ChartNamedElement, IChartMapArea
	{
		private Axis _axis;
		private Color _foreColor;
		private double _fromPosition;
		private GridTickTypes _gridTick;
		private string _image;
		private string _imageMapAreaAttributes;
		private string _imagePostbackValue;
		private Color _imageTransparentColor;
		private string _imageUrl;
		private LabelMarkStyle _labelMark;
		private int _labelRowIndex;
		private string _mapAreaAttributes;
		private Color _markColor;
		private string _postbackValue;
		private string _text;
		private string _tooltip;
		private double _toPosition;
		private string _url;
		internal bool customLabel;

		public CustomLabel()
		{
			this._text = "";
			this._foreColor = Color.Empty;
			this._markColor = Color.Empty;
			this.customLabel = true;
			this._image = string.Empty;
			this._imageTransparentColor = Color.Empty;
			this._tooltip = string.Empty;
			this._imageUrl = string.Empty;
			this._imageMapAreaAttributes = string.Empty;
			this._imagePostbackValue = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
		}

		public CustomLabel(double fromPosition, double toPosition, string text, int labelRow, LabelMarkStyle markStyle)
		{
			this._text = "";
			this._foreColor = Color.Empty;
			this._markColor = Color.Empty;
			this.customLabel = true;
			this._image = string.Empty;
			this._imageTransparentColor = Color.Empty;
			this._tooltip = string.Empty;
			this._imageUrl = string.Empty;
			this._imageMapAreaAttributes = string.Empty;
			this._imagePostbackValue = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this._fromPosition = fromPosition;
			this._toPosition = toPosition;
			this._text = text;
			this._labelRowIndex = labelRow;
			this._labelMark = markStyle;
			this._gridTick = GridTickTypes.None;
		}

		public CustomLabel(double fromPosition, double toPosition, string text, int labelRow, LabelMarkStyle markStyle, GridTickTypes gridTick)
		{
			this._text = "";
			this._foreColor = Color.Empty;
			this._markColor = Color.Empty;
			this.customLabel = true;
			this._image = string.Empty;
			this._imageTransparentColor = Color.Empty;
			this._tooltip = string.Empty;
			this._imageUrl = string.Empty;
			this._imageMapAreaAttributes = string.Empty;
			this._imagePostbackValue = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this._fromPosition = fromPosition;
			this._toPosition = toPosition;
			this._text = text;
			this._labelRowIndex = labelRow;
			this._labelMark = markStyle;
			this._gridTick = gridTick;
		}

		public CustomLabel Clone()
		{
			CustomLabel label = new CustomLabel();
			label.FromPosition = this.FromPosition;
			label.ToPosition = this.ToPosition;
			label.Text = this.Text;
			label.ForeColor = this.ForeColor;
			label.MarkColor = this.MarkColor;
			label.RowIndex = this.RowIndex;
			label.LabelMark = this.LabelMark;
			label.GridTicks = this.GridTicks;
			label.ToolTip = this.ToolTip;
			label.Tag = base.Tag;
			label.Image = this.Image;
			label.ImageTransparentColor = this.ImageTransparentColor;
			label.Url = this.Url;
			label.MapAreaAttributes = this.MapAreaAttributes;
			label.ImageUrl = this.ImageUrl;
			label.ImageMapAreaAttributes = this.ImageMapAreaAttributes;
			return label;
		}

		[SerializationVisibility(SerializationVisibility.Hidden), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public Axis Axis
		{
			get
			{
				return this._axis;
			}
		}

		[SRCategory("CategoryAttributeAppearance"), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(typeof(Color), ""), SRDescription("DescriptionAttributeForeColor"), NotifyParentProperty(true)]
		public Color ForeColor
		{
			get
			{
				return this._foreColor;
			}
			set
			{
				this._foreColor = value;
				this.Invalidate();
			}
		}

		[Bindable(true), SRCategory("CategoryAttributeAppearance"), DefaultValue((double)0.0), SRDescription("DescriptionAttributeCustomLabel_From"), PersistenceMode(PersistenceMode.Attribute), TypeConverter(typeof(AxisLabelDateValueConverter))]
		public double FromPosition
		{
			get
			{
				return this._fromPosition;
			}
			set
			{
				this._fromPosition = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeCustomLabel_GridTicks"), DefaultValue(0), Editor(typeof(FlagsEnumUITypeEditor), typeof(UITypeEditor)), SRCategory("CategoryAttributeAppearance"), Bindable(true)]
		public GridTickTypes GridTicks
		{
			get
			{
				return this._gridTick;
			}
			set
			{
				this._gridTick = value;
				this.Invalidate();
			}
		}

		[Editor(typeof(ImageValueEditor), typeof(UITypeEditor)), NotifyParentProperty(true), Bindable(true), DefaultValue(""), SRDescription("DescriptionAttributeCustomLabel_Image"), SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute)]
		public string Image
		{
			get
			{
				return this._image;
			}
			set
			{
				this._image = value;
				this.Invalidate();
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRDescription("DescriptionAttributeMapAreaAttributes"), SRCategory("CategoryAttributeMapArea"), DefaultValue(""), Bindable(true)]
		public string ImageMapAreaAttributes
		{
			get
			{
				return this._imageMapAreaAttributes;
			}
			set
			{
				this._imageMapAreaAttributes = value;
			}
		}

		[SRCategory("CategoryAttributeMapArea"), DefaultValue(""), SRDescription("DescriptionAttributePostBackValue")]
		public string ImagePostBackValue
		{
			get
			{
				return this._imagePostbackValue;
			}
			set
			{
				this._imagePostbackValue = value;
			}
		}

		[SRDescription("DescriptionAttributeImageTransparentColor"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(typeof(Color), "")]
		public Color ImageTransparentColor
		{
			get
			{
				return this._imageTransparentColor;
			}
			set
			{
				this._imageTransparentColor = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeCustomLabel_ImageUrl"), PersistenceMode(PersistenceMode.Attribute), Editor(typeof(UrlValueEditor), typeof(UITypeEditor)), Bindable(true), SRCategory("CategoryAttributeMapArea"), DefaultValue("")]
		public string ImageUrl
		{
			get
			{
				return this._imageUrl;
			}
			set
			{
				this._imageUrl = value;
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRDescription("DescriptionAttributeCustomLabel_LabelMark"), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0)]
		public LabelMarkStyle LabelMark
		{
			get
			{
				return this._labelMark;
			}
			set
			{
				this._labelMark = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMapArea"), SRDescription("DescriptionAttributeMapAreaAttributes"), DefaultValue(""), PersistenceMode(PersistenceMode.Attribute), Bindable(true)]
		public string MapAreaAttributes
		{
			get
			{
				return this._mapAreaAttributes;
			}
			set
			{
				this._mapAreaAttributes = value;
			}
		}

		[Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), DefaultValue(typeof(Color), ""), SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), SRDescription("DescriptionAttributeCustomLabel_MarkColor"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Bindable(true)]
		public Color MarkColor
		{
			get
			{
				return this._markColor;
			}
			set
			{
				this._markColor = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeAppearance"), DesignOnly(true), SerializationVisibility(SerializationVisibility.Hidden), DefaultValue("Custom LabelStyle"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SRDescription("DescriptionAttributeCustomLabel_Name")]
		public override string Name
		{
			get
			{
				return base.Name;
			}
			set
			{
				base.Name = value;
			}
		}

		internal override IChartElement Parent
		{
			get
			{
				return base.Parent;
			}
			set
			{
				base.Parent = value;
				if (value != null)
				{
					this._axis = this.Parent.Parent as Axis;
				}
			}
		}

		[SRDescription("DescriptionAttributePostBackValue"), DefaultValue(""), SRCategory("CategoryAttributeMapArea")]
		public string PostBackValue
		{
			get
			{
				return this._postbackValue;
			}
			set
			{
				this._postbackValue = value;
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0), SRDescription("DescriptionAttributeCustomLabel_RowIndex")]
		public int RowIndex
		{
			get
			{
				return this._labelRowIndex;
			}
			set
			{
				if (value < 0)
				{
					throw new InvalidOperationException(SR.ExceptionAxisLabelRowIndexIsNegative);
				}
				this._labelRowIndex = value;
				this.Invalidate();
			}
		}

		[SRDescription("DescriptionAttributeCustomLabel_Text"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(""), SRCategory("CategoryAttributeAppearance")]
		public string Text
		{
			get
			{
				return this._text;
			}
			set
			{
				this._text = value;
				this.Invalidate();
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRDescription("DescriptionAttributeToolTip"), DefaultValue(""), SRCategory("CategoryAttributeMapArea"), Bindable(true)]
		public string ToolTip
		{
			get
			{
				return this._tooltip;
			}
			set
			{
				this._tooltip = value;
			}
		}

		[SRDescription("DescriptionAttributeCustomLabel_To"), DefaultValue((double)0.0), SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), TypeConverter(typeof(AxisLabelDateValueConverter)), Bindable(true)]
		public double ToPosition
		{
			get
			{
				return this._toPosition;
			}
			set
			{
				this._toPosition = value;
				this.Invalidate();
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), Editor(typeof(UrlValueEditor), typeof(UITypeEditor)), SRCategory("CategoryAttributeMapArea"), Bindable(true), SRDescription("DescriptionAttributeUrl"), DefaultValue("")]
		public string Url
		{
			get
			{
				return this._url;
			}
			set
			{
				this._url = value;
			}
		}
	}
}

